package com.dimao.certificate_build_service.handle.parallel;

import java.util.ArrayList;
import java.util.List;
import java.util.function.Consumer;

public class ParallelBuilder {
    private List<Consumer<Task>> taskList;

    public ParallelBuilder(Consumer<Task> mainTask){
        taskList = new ArrayList<>();
        taskList.add(mainTask);
    }

    public ParallelBuilder parallelTask(Consumer<Task> task){
        taskList.add(task);
        return this;
    }

    public ParallelBuilder parallelTask(int taskID, Consumer<Task> task){
        taskList.add(taskID, task);
        return this;
    }

    public Parallel build(){
        return new Parallel(taskList);
    }
}
